<?php
/* [DoYouHaoBaby!] (C)Dianniu From 2010.
   this($)*/

!defined('DYHB_PATH') && exit;

class TemplateGtkGladeWidgetCompiler_GtkExpander extends TemplateGtkGladeWidgetCompilerBase{

	protected function compileCreateWidget_(TemplateGtkGladeWidget $oObject){
		$sWidgetClass=$oObject->getWidgetClass();
		$sVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oObject);
		$sCompiled="\t\t{$sVariableName}=new {$sWidgetClass}('');";
		$this->setBool_($oObject,$sCompiled,'expanded');// 展开状态
		$this->setBool_($oObject,$sCompiled,'use_underline');// 使用下划线
		$this->setBool_($oObject,$sCompiled,'use_markup');// 使用标记语言
		$this->setStringInt_($oObject,$sCompiled,'spacing',false);// 间距
		return $sCompiled;
	}

	protected function compileChildWidgetPacking_(TemplateGtkGladeWidget $oParentWidget,TemplateGtkGladeWidget $oChildWidget,TemplateGtkGladeWidgetPacking $oPacking){
		$sParentVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oParentWidget);// 父/子 窗体变量名
		$sChildWidgetVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oChildWidget);
		$sChildWidgetName=$oChildWidget->getWidgetId();// 子窗体名
		$sCompiled="\t\t{$sChildWidgetVariableName}=\$this->getWidget('{$sChildWidgetName}',\$arrObjectForSignal);";
		if($oPacking->getProperty('type')=='label_item'){// 标签
			A::ASSERT_($oChildWidget->getWidgetClass()=='GtkLabel',G::L('GtkExpander 窗体的标签，应该是 GtkLabel 类型，遇到的窗体类型为：“%s”。','Dyhb',null,$oChildWidget->getWidgetClass()));
			$sCompiled.="\t\t{$sParentVariableName}->set_label_widget({$sChildWidgetVariableName});";
		}
		else{$sCompiled.="\t\t{$sParentVariableName}->add({$sChildWidgetVariableName});";}// 主体内容
		return $sCompiled;
	}

	static public function regToProcessorManager(ITemplateObjProcessorManager $oManager){
		$oManager->regProcessor(str_replace('TemplateGtkGladeWidgetCompiler_','',__CLASS__),__CLASS__);
	}

}
